package com.inspur.gs.sbssdl.sbwhgl.bpbjgl.bpbjgl.front.bjckform_frm.voactions;
import com.inspur.edp.bef.api.lcp.ILcpFactory;
import com.inspur.edp.bef.api.lcp.IStandardLcp;
import com.inspur.edp.bef.api.services.IBefSessionManager;
import com.inspur.edp.bff.spi.*;
import com.inspur.edp.bef.api.action.*;
import io.iec.edp.caf.commons.exception.CAFRuntimeException;
import io.iec.edp.caf.commons.exception.ExceptionLevel;
import io.iec.edp.caf.commons.utils.SpringBeanUtils;

public class checkTzLkslVOAction extends AbstractFSAction<VoidActionResult> {

	private String tzid;
	private String sl;
	public checkTzLkslVOAction(String tzid,String sl) {

		this.tzid = tzid;
		this.sl = sl;
	}
	@Override
	public void execute() {
		SpringBeanUtils.getBean(IBefSessionManager.class).createSession();
		try {
			//点检配置变更
			ILcpFactory iLcpFactory = SpringBeanUtils.getBean(ILcpFactory.class);
			String bpbjtzid = "3f443799-4bc1-409f-a28d-f04742273899";
			IStandardLcp tzlcp = iLcpFactory.createLcpByBEId(bpbjtzid);
			Integer lksl = (Integer) tzlcp.retrieve(tzid).getData().getValue("lksl");

			int slInt = Integer.parseInt(sl);

			if (lksl<slInt){
				throw new RuntimeException("该出库数量已超台账数量!");
//				throw new CAFRuntimeException("checkTzLksl", "0001", "该出库数量已超台账数量!", new RuntimeException(), ExceptionLevel.Error, true);
			}

		} finally {
			SpringBeanUtils.getBean(IBefSessionManager.class).closeCurrentSession();
		}
	}
}
